import 'package:flutter/material.dart';
import '../model/post.dart';
import 'post_show_demo.dart';


class listViewDemo extends StatelessWidget{
Widget _listItemBuilder(BuildContext context,int index){
   return Container(
     color: Colors.white,
     margin: EdgeInsets.all(10.0),
     child:Stack(
       children: <Widget>[
           Column(
              children: <Widget>[
               Image.network(posts[index].imageUrl),
               SizedBox(height:10.0),
            Text(
                 posts[index].title,
                 style: Theme.of(context).textTheme.bodyText1,
                ),
              SizedBox(height:10.0),
            Text(
                 posts[index].author,
                 style: Theme.of(context).textTheme.subtitle1,
               ),
              SizedBox(height:10.0)
         ],
     ),
     Positioned.fill(
       child: Material(
       color: Colors.transparent,
       child: InkWell(
          splashColor:Colors.white.withOpacity(0.3),
           highlightColor:Colors.white.withOpacity(0.1),
           onTap: (){
           Navigator.of(context).push(
            MaterialPageRoute(builder: (context) => PostShow(post: posts[index]))
           );
           },
        ),
         )
         )
       ],
     )
   );
}
  @override
  Widget build(BuildContext context){ 
     return ListView.builder(
           itemCount: posts.length, 
           itemBuilder: _listItemBuilder,
         );
   }

}